import { IThemeColor } from '../../../../type/index';

interface IData {
  name: string;
  value: number;
}

export const initWorkType = (echarts: any, dom: HTMLElement, workTypeStuNumList: number[], workTypeList: string[], themeColor: IThemeColor) => {
  let dataList = [] as any;

  workTypeList.forEach((item, index) => {
    dataList.push({
      name: item,
      value: workTypeStuNumList[index],
    });
  });

  const charts = echarts.init(dom);
  charts.setOption({
    title: {
      text: '就业岗位分析',
      textStyle: {
        color: themeColor.font,
        fontSize: 16,
        fontWeight: 'normal',
      },
      padding: [16, 0, 0, 16],
    },

    tooltip: {
      trigger: 'item',
    },
    legend: {
      type: 'scroll',
      top: 'bottom',
      left: 'center',
      pageIconColor: themeColor.font,
      pageTextStyle: {
        color: themeColor.font,
      },
      textStyle: {
        color: themeColor.font,
      },
      itemStyle: {
        borderWidth: 0,
      },
    },
    series: [
      {
        type: 'pie',
        radius: ['0%', '60%'],
        avoidLabelOverlap: false,
        minAngle: 5,
        itemStyle: {
          borderRadius: 8,
        },
        label: {
          color: themeColor.font,
        },
        emphasis: {
          label: {
            show: true,
            fontSize: '16',
            // fontWeight: 'bold',
          },
        },
        data: dataList,
      },
    ],
  });
};
